package com;

import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.security.crypto.password.PasswordEncoder;

import com.xue.dao.UserRepository;
import com.xue.pojo.User;

@SpringBootApplication
public class AuthServerApplication {

	public static void main(String[] args) {
		SpringApplication.run(AuthServerApplication.class, args);
	}

	// 启动时初始化默认数据
	@Bean
	public ApplicationRunner dataLoader(UserRepository repo, PasswordEncoder encoder) {
		return args -> {
			repo.save(new User(1L, "a1", encoder.encode("1"), "ROLE_ADMIN"));
			repo.save(new User(2L, "a2", encoder.encode("1"), "ROLE_ADMIN"));
		};
	}
}
